﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Markup;
using VisualWip.PresentationModel.Text;

namespace VisualWip
{
    /// <summary>
    /// Interaction logic for RichTextSettingsView.xaml
    /// </summary>
    public partial class RichTextSettingsView : UserControl
    {
        public RichTextSettingsView()
        {
            InitializeComponent();
        }

        private void RichTextBoxLostFocus(object sender, RoutedEventArgs e)
        {
            var viewModel = DataContext as RichTextColumnSettingsViewModel;
            
            if (viewModel != null)
                viewModel.SaveDocument(richTextBox.Document);
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var viewModel = DataContext as RichTextColumnSettingsViewModel;
            if (viewModel != null)
                richTextBox.Document = viewModel.GetDocument();
        }
    }
}